<?php

namespace App\Console\Commands;

use EasyWeChat\Factory;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;

class SetWxMenu extends Command
{

    /**
     * bt http://8.140.164.131:8888/EfAqGsKE
     * 6fxSMyAg
     * 1234565
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'menu:wx';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'set wx menu';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return int
     */
    public function handle()
    {   
        Log::info("console");
        
        $config = config('wechat');

        $app = Factory::officialAccount($config);
        $buttons = [
            [
                "type" => "view",
                "name" => "领取福利",
                "url"  => "https://l3y.com/"
            ],
            [
                "type" => "click",
                "name" => "自动回复",
                "key"  => "LB_CODE"
            ],
            [
                "type" => "view",
                "name" => "投诉和建议",
                "url"  => "https://wpa1.qq.com/zcSFBQQr?_type=wpa&qidian=true"
            ]
        ];
        $res = $app->menu->create($buttons);
        dump($res);
    }
}
